package pers.cz.javacvdemo.web;

import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import pers.cz.javacvdemo.common.ResponseResult;
import pers.cz.javacvdemo.redis.RedisService;
import pers.cz.javacvdemo.service.SysFileService;

/**
 * @version 1.0
 * @description:
 * @author: ChengZhi 0336
 * @create: 2025-08-13 16:13
 **/
@RestController
@AllArgsConstructor
@RequestMapping("/sys-file")
public class SysFileController {

	private final SysFileService sysFileService;

	private final RedisService redisService;

	@PostMapping(value = "/upload/{bucketName}")
	public ResponseResult<Void> upload(@PathVariable String bucketName, @RequestPart("file") MultipartFile file) throws Exception {
		sysFileService.uploadFile(bucketName, file);
		return ResponseResult.success();
	}

	@GetMapping("/get")
	public ResponseResult<String> testReidsGet(@RequestParam String key) {

		return ResponseResult.success(redisService.STRING.get(key));
	}
}
